#include<iostream>
using namespace std;
int r1, r2, l1, l2,n;
string s1, s2;
void dfs(int l1,int r1,int l2,int r2)
{
	if (l1 > r1) return;
	int p = l1;
	while (s1[p] != s2[l2]) p++;
	dfs(l1, p - 1, l2 + 1, l2 + p - l1);
	dfs(p + 1, r1, l2 + p - l1 + 1, r2 - 1);
	cout << s2[l2];
}
int main()
{

	cin >> s1 >> s2;
	dfs(l1,s1.size() - 1, l2, s2.size() - 1);
	return 0;
}